<?php
namespace ImiDemo\WebSocketDemo\MainServer\WSController\Index;
 
use Imi\ConnectContext;
use Imi\Controller\WebSocketController;
use Imi\Server\Route\Annotation\WebSocket\WSRoute;
use Imi\Server\Route\Annotation\WebSocket\WSAction;
use Imi\Server\Route\Annotation\WebSocket\WSController;
 
/**
 * 数据收发测试
 * @WSController
 */
class Test extends WebSocketController
{
    /**
     * 登录
     *
     * @WSAction
     * @WSRoute({"action"="login"})
     * @return void
     */
    public function login($data)
    {
        ConnectContext::set('username', $data->username);
        $this->server->joinGroup('g1', $this->frame->getFd());
        return ['success'=>true];
    }
}